﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

using QuDao;
using FineUICore;
using Kalman;
using Kalman.Extensions;

namespace AdminUI.Pages.BaseData
{
    public partial class CategoryEditModel : BaseModel
    {

        public void OnGet(int id)
        {
            Current = CategoryBO.Instance.GetItem<Category>(id);
        }

        public Category Current { get; set; }

        public IActionResult OnPostBtnSubmit_Click(CategoryModifyDto dto)
        {
            try
            {
                CategoryBO.Instance.Modify(dto);

                var js = ActiveWindow.GetHideExecuteScriptReference("onRefreshClick();");
                FineUICore.PageContext.RegisterStartupScript(js); //保存后触发父页面刷新按钮事件

                //FineUICore.PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
                //ActiveWindow.HidePostBack();
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
                if (!(ex is AppException && ex.InnerException == null))
                {
                    msg = ex.ToString();
                }

                Alert.Show(msg, "错误信息", MessageBoxIcon.Error);
            }

            return UIHelper.Result();
        }

    }
}